package cn.hjh.controller;

import cn.hjh.pojo.Goods;
import cn.hjh.service.DeliService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/goods")
public class DeliController {

    private static Logger logger= Logger.getLogger(DeliController.class);

    @Resource
    private DeliService deliService;

    @RequestMapping(value = "/often",method = RequestMethod.GET)
    @ResponseBody
    @CrossOrigin
    public List<Goods> getGoodsList(){
        List<Goods> goodsList = null;
        goodsList = deliService.getGoodsList();
        System.out.println("常用商品" + goodsList);
        return goodsList;
    }

    @RequestMapping(value = "/list",method = RequestMethod.GET)
    @ResponseBody
    @CrossOrigin
    public Object getGoodsByType(){
        Map<String,List<Goods>> resultMap = null;
        resultMap = deliService.getGoodsTypeList();
        return resultMap;
    }
}
